//
//  SeedManager.m
//  17DianYing
//
//  Created by apple on 15/9/19.
//  Copyright (c) 2015年 apple. All rights reserved.
//

#import "SeedManager.h"
#import "AFNetworking.h"


@interface SeedManager()

@property (nonatomic,strong)AFHTTPRequestOperationManager *afManager;
@property(nonatomic,strong)SeedManager *seedM;
@end


@implementation SeedManager


+(instancetype)share
{
    static SeedManager *m = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        m = [[SeedManager alloc]init];
    });
    return m;
}


-(void)seedNewsWithToken:(NSString *)token andMessage:(NSString *)message andGroupId:(NSString *)groupId  BlockHandle:(LondManagerBlock)bh
{
    self.afManager = [[AFHTTPRequestOperationManager alloc]init];
    self.afManager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    NSString * url =[http stringByAppendingString:@"/mobile/group/freedomGroup/sendTextMessage"];
 

    
     NSDictionary * dic = @{@"message":message,@"token":token,@"groupId":groupId};
    
    AFHTTPRequestOperation * op = [self.afManager POST:url parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        id obj = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        NSDictionary *dic = obj;
        bh(dic);
        NSLog(@"%@",dic);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"%@",error.localizedDescription);
    }];
    [op start];

}

@end
